<template>
  <div class="base" v-if="showLogin">

    <div class="app1">
      <input type="text">
      <input type="text">
      <div class="but">
        <button @click="reg">注册</button>
        <button @click="login">登录</button>
      </div>
    </div>
  </div>
  <div v-else>
    <router-view />
  </div>

</template>

<script>
import { useRouter } from 'vue-router'
export default {

  name: 'LoginApp',
  components: {

  },
  data() {
    return {
      showLogin: true
    }
  },
  methods: {
    login() {
      this.showLogin = false
      sessionStorage.setItem('showLogin', '0')

      console.log('login');

      this.$router.push('/LoginDouBao')
    },
    reg() {
      this.showLogin = false
      sessionStorage.setItem('showLogin', '0')
      console.log('reg');

      this.$router.push('/halo')
    }
  }, mounted() {
    sessionStorage.getItem('showLogin') == '0' ? this.showLogin = false : this.showLogin = true
    let router = useRouter()
    console.log('router:', router.currentRoute.value.path);
    this.$nextTick(() => {
      setTimeout(() => {
        console.log('router:', router.currentRoute.value.path);
        let tag1 = sessionStorage.getItem('showLogin')
        console.log('tag1:', tag1);

        if (router.currentRoute.value.path === '/' || router.currentRoute.value.path === '/login') {
          this.showLogin = true
          sessionStorage.setItem('showLogin', '1')
        }
      }
      )
    })
  }

}
</script>

<style>
.but {
  display: flex;
  justify-content: space-around;
}

.base {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

input {
  margin-bottom: 20px;
}

.app1 {
  display: flex;
  flex-direction: column;
  width: 200px;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /* margin-top: 60px; */
}
</style>
